/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package phd.dupenois.datatrees.tree2d;

import java.util.Vector;
import phd.dupenois.changeidentifiers.dotpatterns.Range;
import phd.dupenois.datatrees.Node;
import uk.co.dupenois.geometry.Coordinate;


/**
 *
 * @author mpd209
 */
public class Node2D extends Node<Coordinate>{
    public Node2D(){}

    private boolean horizontal;
    private Range myRange;
    

    public Vector<Node2D> search(Range range){
        Vector<Node2D> leaves = new Vector<Node2D>();
        if(this.isLeaf()){
            if(range.in(this.getValue())) leaves.add(this);
        }else if(myRange.in(range)){
            if(this.hasLeft())
                leaves.addAll(((Node2D)this.getLeft()).search(range));
            if(this.hasRight())
                leaves.addAll(((Node2D)this.getRight()).search(range));
        }
        return leaves;
    }
    
    /**
     * @return the horizontal
     */
    public boolean isHorizontal() {
        return horizontal;
    }

    /**
     * @param horizontal the horizontal to set
     */
    public void setHorizontal(boolean horizontal) {
        this.horizontal = horizontal;
    }

    /**
     * @return the range
     */
    public Range getRange() {
        return myRange;
    }

    /**
     * @param range the range to set
     */
    public void setRange(Range range) {
        this.myRange = range;
    }

}
